//
//  YBFourTableViewCell.m
//  GoodBuy
//
//  Created by dlios on 15-5-27.
//  Copyright (c) 2015年 GoodBuy. All rights reserved.
//

#import "YBFourTableViewCell.h"
#import "UIImageView+WebCache.h"

@implementation YBFourTableViewCell

- (void)awakeFromNib {
    // Initialization code
}
- (void)dealloc
{
    [_Mall release];
    [_Title release];
    [_picture release];
    [_Price release];
    [super dealloc];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 8, [UIScreen mainScreen].bounds.size.width-15,self.contentView.frame.size.height*3)];
        NSLog(@"jkbhjgjh %f",self.contentView.frame.size.height);
        backgroundImageView.image = [UIImage imageNamed:@"event"];
        
        [self.contentView addSubview:backgroundImageView];
        self.picture = [[UIImageView alloc] init];
        _picture.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_picture];
        [_picture release];
        
        self.Title = [[UILabel alloc] init];
//        _Title.backgroundColor = [UIColor yellowColor];
          [_Title setFont:[UIFont systemFontOfSize:15]];
        [self.contentView addSubview:_Title];
        [_Title release];
        
        self.Price = [[UILabel alloc] init];
//        _Price.backgroundColor = [UIColor cyanColor];
        [_Price setFont:[UIFont systemFontOfSize:15]];
        _Price.textColor = [UIColor redColor];
        [self.contentView addSubview:_Price];
        [_Price release];
        
        
        self.Mall = [[UILabel alloc] init];
//        _Mall.backgroundColor = [UIColor greenColor];
        [_Mall setFont:[UIFont systemFontOfSize:15]];
        [self.contentView addSubview:_Mall];
        [_Mall release];
        
    }
    return self;
}

- (void)layoutSubviews
{
    //  1. 一定要调用父类方法
    [super layoutSubviews];
    
    //设置子视图frame
    
    _picture.frame = CGRectMake(20, 15,[UIScreen mainScreen].bounds.size.width/4.4, self.contentView.frame.size.height-30);
    
    _Title.frame = CGRectMake(_picture.frame.origin.x + _picture.frame.size.width + 10, _picture.frame.origin.y, _picture.frame.size.width*2.8, _picture.frame.size.height/4);
    
    _Price.frame = CGRectMake(_Title.frame.origin.x, _Title.frame.origin.y + _Title.frame.size.height+10, _Title.frame.size.width, _Title.frame.size.height);
    
    _Mall.frame = CGRectMake(_Price.frame.origin.x, _Price.frame.origin.y + _Price.frame.size.height + 10, _Title.frame.size.width, _Title.frame.size.height);
}

//重写SET方法
- (void)setStu:(YBForeignObject *)Stu
{
    if (Stu != _Stu) {
        [_Stu release];
        _Stu = [Stu retain];
    }
    //给控件赋值
    [_picture sd_setImageWithURL:[NSURL URLWithString:Stu.article_pic]placeholderImage:[UIImage imageNamed:@"zhanweitu"]];
    _Title.text = Stu.article_title;
    _Price.text = Stu.article_price;
    _Mall.text = Stu.article_mall;
}
@end
